package com.hksj.ecm.controller;

import com.hksj.common.core.model.Rest;
import com.hksj.ecm.entity.EnergyType;
import com.hksj.ecm.service.EnergyTypeService;
import com.hksj.ecm.vo.EnergyTypeVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author zengke
 * @version 1.0
 * @see EnergyTypeController
 * @since 2024/8/6 17:21
 */

@Api(tags = "能耗监测-能耗类型管理")
@RequestMapping("/api/energyType")
@RestController
public class EnergyTypeController {

    @Autowired
    private EnergyTypeService energyTypeService;

    @ApiOperation(value = "同步能耗类型数据")
    @GetMapping("/syncEnergyType")
    public Rest<String> syncEnergyType(){
        String result = energyTypeService.syncEnergyType();
        return Rest.ok(result);
    }

    @ApiOperation(value = "查询能耗类型树")
    @GetMapping("/queryEnergyTypeTree")
    public Rest<List<EnergyType>> queryEnergyTypeTree(){
        List<EnergyType> energyTypeList = energyTypeService.queryEnergyTypeTree();
        return Rest.ok(energyTypeList);
    }

    @ApiOperation(value = "维护能耗类型")
    @PutMapping("/maintenanceEnergyType")
    public Rest<String> maintenanceEnergyType(@RequestBody EnergyType energyType){
        String result = energyTypeService.maintenanceEnergyType(energyType);
        return Rest.ok(result);
    }

    @ApiOperation(value = "查询能耗类型明细")
    @GetMapping("/queryEnergyTypeDetail")
    public Rest<EnergyTypeVO> queryEnergyTypeDetail(String energyTypeCode){
        EnergyTypeVO energyType = energyTypeService.queryEnergyTypeDetail(energyTypeCode);
        return Rest.ok(energyType);
    }

}
